<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>用户注册</title>
</head>
<body>
<form action="" method="post" onsubmit="return checkform()">
    <table>
        <tr>
            <td>登录名</td>
            <td>
                <input id="dlm" name="dlm" placeholder="请输入用户名" type="text"/>
            </td>
            <td>
                动态显示验证结果
            </td>
        </tr>
        <tr>
            <td>密码</td>
            <td>
                <input id="mm" name="mm" placeholder="请输入密码" type="password"/>
            </td>
            <td>密码至少六位</td>
        </tr>
        <tr>
            <td>确认密码</td>
            <td>
                <input id="qrmm" name="" placeholder="请确认密码" type="password"/>
            </td>
            <td>确认密码必须与密码一致</td>
        </tr>
        <tr>
            <td>性别</td>
            <td>
                <input checked="checked" name="sex" type="radio" value="male"/>男
                <input name="sex" type="radio" value="female"/>女
            </td>
        </tr>
        <tr>
            <td>电话</td>
            <td>
                <input id="dh" name="dh" placeholder="请输入十一位电话号码" type="tel"/>
            </td>
        </tr>
        <tr>
            <td>籍贯</td>
            <td>
                <select name="sheng">
                    <option value="1">山东省</option>
                    <option value="2">江苏省</option>
                </select>
                <select name="shi">
                    <option value="01">青岛市</option>
                    <option value="02">烟台市</option>
                </select>
            </td>
            <td></td>
        </tr>
        <tr>
            <td align="center" colspan="3">
                <button type="submit">注册</button>
                <button type="reset">清空</button>
            </td>
        </tr>
    </table>
</form>
</body>
<script type="text/javascript">
    function checkform() {
        alert("nihao ");
        var xm = document.getElementById("dlm").value;
        var mm = document.getElementById("mm").value;
        var qrmm = document.getElementById("qrmm").value;
        if (xm == "" || xm.length < 6 || xm.length > 12) {
            xm.innerHTML = "用户输入有误";
            return false;
        }
        if (mm == "" || mm.length < 6) {
            alert("请输入正确的密码");
            return false;
        }
        if (remm != mm) {
            alert("密码不一致");
            return false;
        }
    }
</script>
</html>
